﻿




function change_pwd() {

    var username = $("#username").val();
    var new_pwd = $("#newpassword").val();
    if (isUndefinedNullOrEmpty(username) || isUndefinedNullOrEmpty(new_pwd)) {
        alert("用户名或密码不能为空");
    }
    else {
        // poststr = "{\"type\":\"fa_qi_activity\",\"activity_name\":\"" + name + "\",\"activity_id\":\"" + guid1 + "\",\"begin_time\":\"" + begin_time + "\",\"end_time\":\"" + end_time + "\",\"text\":\"" + text1 + "\"}";
        poststr = "{\"type\":\"change_pwd\",\"username\":\"" + username + "\",\"password\":\"" + $.md5(new_pwd) + "\"}";
        mj_js_ajax("json", poststr, change_atate);
    }
}
function change_atate(data) {
    if (data.result == "ok") {
        alert(data.msg);
    }

}
function get_user(index) {
    poststr = "{\"type\":\"get_manager\",\"page\":\"" + index + "\"}";
    mj_js_ajax("json", poststr, show_list);

}
function show_list(data) {
    $("#tbodyList").empty();
    var result = data.result;
    var data_table = data.table;
    var allcount = data.record_count;
    var current_page = data.page_curent;
    var tcount = 0;
    var table = document.getElementById("tbodyList");
    if (result == "ok") {
        var str = "";
        try {

            for (var i = 0; i < data_table.length; i++) {

                if (tcount % 2 == 0) {
                    var tr = document.createElement("tr");
                    var td1 = document.createElement("td");
                    td1.innerHTML = data_table[i].id;
                    var td2 = document.createElement("td");
                    td2.innerHTML = data_table[i].username;
                    var td3 = document.createElement("td");
                    td3.innerHTML = change_datatime_form(data_table[i].createtime);
                    var td4 = document.createElement("td");
                    var obj_input = document.createElement("input");
                    obj_input.setAttribute("type", "button");
                    obj_input.setAttribute("value", "删  除");
                    obj_input.className = "btn btn-info";
                    obj_input.id = data_table[i].id;
                    obj_input.onclick = function () {
                        deletct(this.id);
                    };
                    td4.appendChild(obj_input);
                    tr.appendChild(td1);
                    tr.appendChild(td2);
                    tr.appendChild(td3);
                    tr.appendChild(td4);
                    table.appendChild(tr);
                    tcount++;
                }
                else {
                    var tr = document.createElement("tr");
                    tr.className = "active";
                    var td1 = document.createElement("td");
                    td1.innerHTML = data_table[i].id;
                    var td2 = document.createElement("td");
                    td2.innerHTML = data_table[i].username;
                    var td3 = document.createElement("td");
                    td3.innerHTML = change_datatime_form(data_table[i].createtime);
                    var td4 = document.createElement("td");
                    var obj_input = document.createElement("input");
                    obj_input.setAttribute("type", "button");
                    obj_input.setAttribute("value", "删  除");
                    obj_input.className = "btn btn-info";
                    obj_input.id = data_table[i].id;
                    obj_input.onclick = function () {
                        deletct(this.id);
                    };
                    td4.appendChild(obj_input);
                    tr.appendChild(td1);
                    tr.appendChild(td2);
                    tr.appendChild(td3);
                    tr.appendChild(td4);
                    table.appendChild(tr);
                    tcount++;
                }
            }
        }
        catch (e) {
        }

    }
}
function deletct(id) {

    poststr = "{\"type\":\"delete_manager\",\"page1\":\"" + id + "\"}";
    mj_js_ajax("json", poststr, show_list);

}
function yes_button() {
    alert("hfeugh7ur");
}

function delete_result(data) {
    var ijhi = "";
    if (data.result == "ok") {
        location.reload();
    }
    else {
        alert("删除失败");
    }
}
function change_datatime_form(time) {
    var result_time = "";
    var time_array = time.split("-");
    result_time += time_array[0] + "年" + time_array[1] + "月" + time_array[2].substr(0, 2) + "日";
    return result_time;
}

